#sign tools.first param is privateKey 

import sys

from blspy import PrivateKey, AugSchemeMPL

from chia.util.hash import std_hash

from clvm.casts import int_to_bytes

from functools import reduce

def convert_bytes(key):
	key,value = key.split("=")
	if key == "hex":
		return bytes.fromhex(value)
	if key == "int":
		return int_to_bytes(int(value))
	if key == "str":
		return str.encode(value)
	raise Exception("the key not suport to convert bytes",key)

params = list(map(lambda x: convert_bytes(x),sys.argv[1:]))

SK = PrivateKey.from_bytes(params[0])

solutionSum=reduce(lambda x,y:x+y,params[1:])

signature = AugSchemeMPL.sign(SK, std_hash(solutionSum))

print(str(signature))



